﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace QUAN_LY_THU_VIEN
{
   public class Login : Conn
    {
       /* public SqlConnection GetCon()
        {
            return new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=D:\\Du Lieu\\ViRus\\QUANLYDULICH.mdf;Integrated Security=True;User Instance=True");

        }*/
        public bool CheckLoginNhanVien(string name, string pass)
        {

            SqlConnection con = Conn.GetCon();
            string sql;
            sql = ("select * from DANGNHAP where TENDANGNHAP='" + name + "' and MATKHAU='" + pass + "'");
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {
               
                con.Close();
                return true;
            }
            else
            {
                con.Close();
                return false;

            }
        
        
        }
        public bool CheckLoginDocGia(string name, string pass)
        {

            SqlConnection con = Conn.GetCon();
            string sql;
            sql = ("select * from THONGTINDOCGIA where TENDANGNHAP='" + name + "' and MATKHAUDOCGIA='" + pass + "'");
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.Read())
            {

                con.Close();
                return true;
            }
            else
            {
                con.Close();
                return false;

            }


        }
    
    }
}
